#!/bin/bash
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3
PATH="/bin:/sbin:/usr/bin:/usr/sbin"

Ok_name=''
Fail_name=''
Judge=0


touch /tmp/testfs
if [ -e /scratch ]
then
        touch /scratch/testfs
        Lmount="root scratch tmp"
else
        Lmount="root tmp"
fi

for choice in $Lmount
do
        case $choice in
        root)
                if [ -w /usr/lib64/nagios/plugins/diskmonitor ]
                then
                    Ok_name="${Ok_name} /${choice}"
                else
                    Judge=1
                    Fail_name="${Fail_name} /${choice}"
                fi
                ;;

        scratch)
                if [ -w /scratch/testfs ]
                then
                    Ok_name="${Ok_name} /${choice}"
                else
                    Judge=1
                    Fail_name="${Fail_name} /${choice}"
                fi
                ;;

        tmp)
                if [ -w /tmp/testfs ]
                then
                    Ok_name="${Ok_name} /${choice}"
                else
                    Judge=1
                    Fail_name="${Fail_name} /${choice}"
                fi
                ;;

        esac

done


if [ $Judge -eq 1 ]
then
        echo "$Fail_name disk space can not write"
        exit $CRITICAL
else
        echo " $Ok_name disk are OK "
        exit $OK
fi

